package com.example.shopserver.web;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ： yy
 * @date ：Created in 19-8-21 上午9:51
 * @description：
 * @modified By：
 * @version: $
 */
@RestController
public class RabbitCotroller {

    @Autowired
    private AmqpTemplate amqpTemplate;

    @GetMapping("/send")
    public void send(){
        //                                 路由，　　　　　　key,　　　　　消息
        amqpTemplate.convertAndSend("MyExchange1","key1","哈赛ｋｉ!!");
        //                         　　 路由　　　　　　　消息


    }
    @GetMapping("/test")
    public String test(){
        return "有机老拉我苦练";
    }

    @GetMapping("/send2")
    public void send2(){
        amqpTemplate.convertAndSend("MyQue1","一库!!!!");
//        amqpTemplate.convertAndSend("MyQue1","dd","fasf"); //
//        amqpTemplate.convertAndSend("MyExchange1","dd","gagagaga");
////        amqpTemplate.convertAndSend("MyExchange1","dadadadada");
//        amqpTemplate.convertAndSend("MyQue1","发发发发发");
    }

    @GetMapping("/send3")
    public void send3(){
        amqpTemplate.convertAndSend("MyExchange1","dadadadada");
    }

    @GetMapping("/hello")
    public String hello(@RequestParam(value = "name")String name){
        return "success!! name = "+name;
    }
}
